package cn.kgc.ssm.service.impl;

import cn.kgc.ssm.mapper.ActivityMapper;
import cn.kgc.ssm.mapper.MemberMapper;
import cn.kgc.ssm.mapper.MessageMapper;
import cn.kgc.ssm.response.ResponseResult;
import cn.kgc.ssm.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 课工场
 * @date 2024/11/23
 * @description
 */
@Service
public class EchartsServiceImpl implements EchartsService {


    @Autowired
    private MemberMapper memberMapper;

    @Autowired
    private ActivityMapper activityMapper;

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public ResponseResult dashboardData() {

        //  新会员
        Integer countMember = memberMapper.selectDashboardData();

        // 新活动
        Integer countActivity = activityMapper.selectDashboardData();

        // 新留言
        Integer countMessage = messageMapper.selectDashboardData();

        HashMap<String, Integer> dashboardData = new HashMap<>();
        dashboardData.put("member",countMember);
        dashboardData.put("activity",countActivity);
        dashboardData.put("message",countMessage);

        // {member:10,activity:20,message:30}
        return ResponseResult.success().data(dashboardData);
    }

    @Override
    public ResponseResult lineData() {
         List<Map<String,Integer>> lineData =    memberMapper.selectLineData();
         lineData.forEach(System.out::println);
         return ResponseResult.success().data(lineData);
    }

    @Override
    public ResponseResult roseData() {

        List<Map<String,Integer>>  roseData =   memberMapper.selectRoseData();
        return ResponseResult.success().data(roseData);
    }
}
